package client;

import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;

import util.Constant;

public class Client {
	
	private String serverAddress;
	private int port;
	
	public Client(String serverAddress,int port) throws UnknownHostException, IOException{
		this.serverAddress = serverAddress;
		this.port = port;		
	}
	
	public void setGet(String file) throws IOException{
		TaskClient tskCli = new TaskClient(new Socket(serverAddress, port));
		tskCli.setGet(file);
		tskCli.start();		
	}
	
	public void setPut(String pathFile) throws IOException{
		TaskClient tskCli = new TaskClient(new Socket(serverAddress, port));
		tskCli.setPut(pathFile);
		tskCli.start();		
	}
	
	public static void main(String[] args) {
		try {
			String addres = Constant.SERVER_ADDRES;
			if(args.length==1) addres = args[0];
				
			Client client = new Client(addres, Constant.SERVER_PORT);			
			
			client.setPut("arquivosGrandes/arq (1).pdf");
			client.setPut("arquivosGrandes/arq (2).pdf");
			client.setPut("arquivosGrandes/arq (3).pdf");
			client.setPut("arquivosGrandes/arq (4).pdf");
			client.setPut("arquivosGrandes/arq (5).pdf");
			client.setPut("arquivosGrandes/arq (6).pdf");
			client.setPut("arquivosGrandes/arq (7).pdf");
			client.setPut("arquivosGrandes/arq (8).pdf");
			client.setPut("arquivosGrandes/arq (9).pdf");
			client.setPut("arquivosGrandes/arq (10).pdf");
			client.setPut("arquivosGrandes/arq (11).pdf");
			client.setPut("arquivosGrandes/arq (12).pdf");
			client.setPut("arquivosGrandes/arq (13).pdf");
			client.setPut("arquivosGrandes/arq (14).pdf");
			client.setPut("arquivosGrandes/arq (15).pdf");
			client.setPut("arquivosGrandes/arq (16).pdf");
			//client.setGet("arq (1).pdf");
			
		} catch (UnknownHostException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
